package com.holin.codenav.controller;

import com.holin.codenav.entity.User;
import org.springframework.web.bind.annotation.*;

@RestController
public class HelloController {
//    @GetMapping("/hello")
    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    public String hello(String nickname,String email){
        return "hello " + nickname + "  "+email;
    }

    @RequestMapping(value = "/hello2",method = RequestMethod.GET)
    public String hello2(@RequestParam(value = "nickname",required = false) String name, String email){
        return "hello " + name + "  "+email;
    }

    @RequestMapping(value = "/helloPost1",method = RequestMethod.POST)
    public String helloPost1(String name, String email){
        System.out.println(name+": "+email);
        return "success";
    }

    @RequestMapping(value = "/helloPost2",method = RequestMethod.POST)
    public String helloPost2(User user){
        System.out.println(user);
        return "success";
    }

    @RequestMapping(value = "/helloPost3",method = RequestMethod.POST)
//    前端传的是对象就用@RequestBody注解接收参数
    public String helloPost3(@RequestBody User user){
        System.out.println(user);
        return "success";
    }
}
